class Solution(object):
    def minEatingSpeed(self, piles, h):
        """
        :type piles: List[int]
        :type h: int
        :rtype: int
        """
        def is_finish_eating(piles, k, h):
            hours = 0
            for i in piles:
                hours += (i + k - 1) // k
            return hours <= h

        l = 1
        r = max(piles)
        while l <= r:
            mid = (l + r) >> 1
            #吃不完
            if not is_finish_eating(piles, mid, h):
                l = mid + 1
            else:
                r = mid - 1
        return l
